import React, { Component } from 'react'
import { connect } from 'dva';

import { Tabs } from 'antd';

import Done from './components/Done';
import Todo from './components/Todo';
import { checkInit } from '@/utils/util';

const TabPane = Tabs.TabPane;

interface IProps {
  dispatch?: Function
}

@connect()
class index extends Component<IProps> {

  componentDidMount() {
    checkInit();
  }

  callback = (key) => {
    sessionStorage.setItem('def_key', key);
  };

  render() {
    const defKey = sessionStorage.getItem('def_key') || '1';

    return (
      <>
        <Tabs onChange={this.callback} defaultActiveKey={defKey}>
          <TabPane tab="待处理" key="1">
            <Todo />
          </TabPane>
          <TabPane tab="已处理" key="2">
            <Done />
          </TabPane>
        </Tabs>
      </>
    )
  }
}

export default index;
